<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">
<ui:composition template="/layouts/default.xhtml">
    <ui:define name="title">#{text['userList.title']}</ui:define>
    <ui:param name="menu" value="AdminMenu"/>

    <ui:define name="body">
        <div class="col-sm-10">
            <h2>#{text['userList.heading']}</h2>

            <h:form id="searchForm" styleClass="form-inline">
                <div id="search" class="text-right">
                    <span class="col-sm-9">
                        <h:inputText id="q" size="20" value="#{userList.query}" styleClass="form-control input-sm"/>
                    </span>
                    <h:commandButton styleClass="btn btn-default btn-sm" action="#{userList.search}" value="#{text['button.search']}"/>
                </div>
            </h:form>

            <h:form id="editUser">

                <div id="actions" class="btn-group">
                    <!-- <script> shows up here and causes square corners on the Add button below -->
                    <h:commandButton action="#{userForm.add}" value="#{text['button.add']}" id="add"
                                     styleClass="btn btn-primary">
                        <f:param name="from" value="list"/>
                    </h:commandButton>
                    <h:commandButton value="#{text['button.done']}" action="home" id="cancel"
                                     immediate="true" styleClass="btn btn-default">
                    </h:commandButton>
                </div>

                <p:dataTable id="users" var="user" value="#{userList.users}" sortBy="#{userList.sortColumn}"
                             paginator="true" rows="25"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="5,10,15">
                    <p:column style="width: 25%">
                        <f:facet name="header">
                            <p:column sortBy="username">
                                <h:outputText value="#{text['user.username']}"/>
                            </p:column>
                        </f:facet>
                        <h:commandLink action="#{userForm.edit}" value="#{user.username}">
                            <f:param name="id" value="#{user.id}"/>
                            <f:param name="from" value="list"/>
                        </h:commandLink>
                    </p:column>
                    <p:column style="width: 34%">
                        <f:facet name="header">
                            <p:column sortBy="fullName">
                                <h:outputText value="#{text['activeUsers.fullName']}"/>
                            </p:column>
                        </f:facet>
                        <h:outputText value="#{user.fullName}"/>
                    </p:column>
                    <p:column style="width: 25%">
                        <f:facet name="header">
                            <p:column sortBy="email">
                                <h:outputText value="#{text['user.email']}"/>
                            </p:column>
                        </f:facet>
                        <h:outputLink value="mailto:#{user.email}">
                            <h:outputText value="#{user.email}"/>
                        </h:outputLink>
                    </p:column>
                    <p:column style="width: 16%">
                        <f:facet name="header">
                            <p:column sortBy="enabled">
                                <h:outputText value="#{text['user.enabled']}"/>
                            </p:column>
                        </f:facet>
                        <h:selectBooleanCheckbox value="#{user.enabled}" disabled="true"/>
                    </p:column>
                </p:dataTable>
            </h:form>
        </div>
    </ui:define>
</ui:composition>
</html>